package org.jeecg.modules.phone.mapper;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.phone.entity.PhoneEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.phone.entity.PhoneEntityVo;

/**
 * @Description: 实体手机管理
 * @Author: jeecg-boot
 * @Date:   2022-08-29
 * @Version: V1.0
 */
public interface PhoneEntityMapper extends BaseMapper<PhoneEntity> {
    @Select("SELECT e.*, t.task_name FROM  phone_entity e " +
            "LEFT JOIN phone_entity_task_resource r   ON r.entity_id = e.id and r.resource_status =1 " +
            "LEFT JOIN phone_task t ON r.task_id = t.id " +
            " ${ew.customSqlSegment}")
    IPage<PhoneEntityVo> searchList(Page<PhoneEntity> page, @Param("ew") Wrapper<PhoneEntity> queryWrapper);

//    @Update("update  phone_entity  " +
//            "SET entity_status='离线'  " +
//            "where update_time < DATE_ADD(NOW(),INTERVAL -60 SECOND)")
    @Update("update  phone_entity  " +
            "SET entity_status='离线'  " +
            "where update_time < DATE_ADD(NOW(),INTERVAL -60 SECOND)")
    void updateOffLine();


}
